package com.cy.controller;

import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
@RestController
public class AjaxController {
    private List<String> list = new ArrayList<>();

    @PostMapping("doSave")
    public String doSave(String name){
        list.add(name);
        return "save ok";
    }

    @GetMapping("/doCheck")
    public String doCheck(String name) {
        return list.contains(name) ? name + "已存在" : name + "可注册";
    }

    @CrossOrigin
    @GetMapping("doAjaxGet")
    public String doAjaxGet() {
        return "Ajax Get request Result";
    }
}
